﻿using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace Dal
{
    public class DbHouseNumberDal
    {
        public DbHouseNumberDal() { }

        #region Select
        public static DataSet Select()
        {
            string sql = "select a.* from DbHouseNumber a ";
            return SqlHelper.Select(sql);
        }

        public static DbHouseNumber Select(Int32 houseNumberID)
        {
            DbHouseNumber DbHouseNumber = null;
            string sql = @"select a.* from DbHouseNumber a  where a.houseNumberID= {0} ";
            sql = string.Format(sql, houseNumberID);
            DataSet ds = SqlHelper.Select(sql);
            if (SqlHelper.HasRow(ds))
                DbHouseNumber = new DbHouseNumber(ds.Tables[0].Rows[0]);
            return DbHouseNumber;
        }

        public static DataSet Select(string where)
        {
            if (where.Trim().ToLower().StartsWith("where"))
                where = where.Substring(5);
            if (!where.Trim().ToLower().StartsWith("and") && where.Trim().Length > 0)
                where = " and " + where;
            string sql = "select a.* from DbHouseNumber a  where 1=1 " + where;
            sql += " order by sort asc ";
            return SqlHelper.Select(sql);
        }

        #endregion Select
    }
}
